package cease.command.block;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.Option;

import cease.butter.BlockExecutor;
import cease.command.HasOptionCommand;
import cease.urs.Session;

/**
 * @author dhf
 */
public class CheckBlockCommand extends HasOptionCommand {
    @Option(name = "-u", usage = "user, email or userid", metaVar = "required", required = true)
    private String user;

    private void reset() {
        user = null;
    }

    public String getCmdDesc() {
        return "check a user whether in block list";
    }

    public void run(Session session, String[] args) throws Exception {
        try {
            parser.parseArgument(args);
            BlockExecutor.getInstance().check(session, user);
            System.out.println(user + " is in block list");
        } catch (CmdLineException e) {
            parser.printUsage(System.out);
        } finally {
            reset();
        }
    }

}
